library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.0 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(p8105.datasets)
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:ggplot2':
##
## last_plot
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following object is masked from 'package:graphics':
##
## layout
data(ny_noaa)
ny_noaa=ny_noaa
I will first tidy the data set. It is important to standardize some
of the values including, snow, tmax,
tmin, and prcp.
ny_noaa <- ny_noaa %>%
janitor::clean_names() %>%
separate(date, into=c("year", "month", "day"), sep= "-") %>%
mutate(tmax = as.numeric(tmax)/10,
tmin = as.numeric(tmin)/10,
prcp = as.numeric(prcp)/10,
snow_mm=snow,
snow=round(snow_mm*0.03937*4)/4) %>%
drop_na() %>%
select(-snow)
I will create a boxplot for one of my plots for the flexdashboard.
ny_noaa %>%
plot_ly(x=~year, y = ~snow_mm, color = ~year, type = "box", colors = "viridis")